<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - self_test2.info - network_io/unix/sockopt.c</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../index.html">top level</a> - <a href="index.html">network_io/unix</a> - sockopt.c<span style="font-size: 80%;"> (source / <a href="sockopt.c.func.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">self_test2.info</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">43</td>
            <td class="headerCovTableEntry">102</td>
            <td class="headerCovTableEntryLo">42.2 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2011-07-03</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">4</td>
            <td class="headerCovTableEntry">8</td>
            <td class="headerCovTableEntryLo">50.0 %</td>
          </tr>
          <tr>
            <td></td>
            <td></td>
            <td></td>
            <td class="headerItem">Branches:</td>
            <td class="headerCovTableEntry">34</td>
            <td class="headerCovTableEntry">105</td>
            <td class="headerCovTableEntryLo">32.4 %</td>
          </tr>
          <tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">           Branch data     Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>                :            : /* Licensed to the Apache Software Foundation (ASF) under one or more</a>
<span class="lineNum">       2 </span>                :            :  * contributor license agreements.  See the NOTICE file distributed with
<span class="lineNum">       3 </span>                :            :  * this work for additional information regarding copyright ownership.
<span class="lineNum">       4 </span>                :            :  * The ASF licenses this file to You under the Apache License, Version 2.0
<span class="lineNum">       5 </span>                :            :  * (the &quot;License&quot;); you may not use this file except in compliance with
<span class="lineNum">       6 </span>                :            :  * the License.  You may obtain a copy of the License at
<span class="lineNum">       7 </span>                :            :  *
<span class="lineNum">       8 </span>                :            :  *     http://www.apache.org/licenses/LICENSE-2.0
<span class="lineNum">       9 </span>                :            :  *
<span class="lineNum">      10 </span>                :            :  * Unless required by applicable law or agreed to in writing, software
<span class="lineNum">      11 </span>                :            :  * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
<span class="lineNum">      12 </span>                :            :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<span class="lineNum">      13 </span>                :            :  * See the License for the specific language governing permissions and
<span class="lineNum">      14 </span>                :            :  * limitations under the License.
<span class="lineNum">      15 </span>                :            :  */
<span class="lineNum">      16 </span>                :            : 
<span class="lineNum">      17 </span>                :            : #include &quot;apr_arch_networkio.h&quot;
<span class="lineNum">      18 </span>                :            : #include &quot;apr_strings.h&quot;
<span class="lineNum">      19 </span>                :            : 
<a name="20"><span class="lineNum">      20 </span>                :            : </a>
<span class="lineNum">      21 </span>                :            : static apr_status_t soblock(int sd)
<span class="lineNum">      22 </span>                :<span class="lineNoCov">          0 : {</span>
<span class="lineNum">      23 </span>                :            : /* BeOS uses setsockopt at present for non blocking... */
<span class="lineNum">      24 </span>                :            : #ifndef BEOS
<span class="lineNum">      25 </span>                :            :     int fd_flags;
<span class="lineNum">      26 </span>                :            : 
<span class="lineNum">      27 </span>                :<span class="lineNoCov">          0 :     fd_flags = fcntl(sd, F_GETFL, 0);</span>
<span class="lineNum">      28 </span>                :            : #if defined(O_NONBLOCK)
<span class="lineNum">      29 </span>                :<span class="lineNoCov">          0 :     fd_flags &amp;= ~O_NONBLOCK;</span>
<span class="lineNum">      30 </span>                :            : #elif defined(O_NDELAY)
<span class="lineNum">      31 </span>                :            :     fd_flags &amp;= ~O_NDELAY;
<span class="lineNum">      32 </span>                :            : #elif defined(FNDELAY)
<span class="lineNum">      33 </span>                :            :     fd_flags &amp;= ~FNDELAY;
<span class="lineNum">      34 </span>                :            : #else
<span class="lineNum">      35 </span>                :            : #error Please teach APR how to make sockets blocking on your platform.
<span class="lineNum">      36 </span>                :            : #endif
<span class="lineNum">      37 </span>        [<span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (fcntl(sd, F_SETFL, fd_flags) == -1) {</span>
<span class="lineNum">      38 </span>                :<span class="lineNoCov">          0 :         return errno;</span>
<span class="lineNum">      39 </span>                :            :     }
<span class="lineNum">      40 </span>                :            : #else
<span class="lineNum">      41 </span>                :            :     int on = 0;
<span class="lineNum">      42 </span>                :            :     if (setsockopt(sd, SOL_SOCKET, SO_NONBLOCK, &amp;on, sizeof(int)) &lt; 0)
<span class="lineNum">      43 </span>                :            :         return errno;
<span class="lineNum">      44 </span>                :            : #endif /* BEOS */
<span class="lineNum">      45 </span>                :<span class="lineNoCov">          0 :     return APR_SUCCESS;</span>
<span class="lineNum">      46 </span>                :            : }
<a name="47"><span class="lineNum">      47 </span>                :            : </a>
<span class="lineNum">      48 </span>                :            : static apr_status_t sononblock(int sd)
<span class="lineNum">      49 </span>                :<span class="lineCov">          6 : {</span>
<span class="lineNum">      50 </span>                :            : #ifndef BEOS
<span class="lineNum">      51 </span>                :            :     int fd_flags;
<span class="lineNum">      52 </span>                :            : 
<span class="lineNum">      53 </span>                :<span class="lineCov">          6 :     fd_flags = fcntl(sd, F_GETFL, 0);</span>
<span class="lineNum">      54 </span>                :            : #if defined(O_NONBLOCK)
<span class="lineNum">      55 </span>                :<span class="lineCov">          6 :     fd_flags |= O_NONBLOCK;</span>
<span class="lineNum">      56 </span>                :            : #elif defined(O_NDELAY)
<span class="lineNum">      57 </span>                :            :     fd_flags |= O_NDELAY;
<span class="lineNum">      58 </span>                :            : #elif defined(FNDELAY)
<span class="lineNum">      59 </span>                :            :     fd_flags |= FNDELAY;
<span class="lineNum">      60 </span>                :            : #else
<span class="lineNum">      61 </span>                :            : #error Please teach APR how to make sockets non-blocking on your platform.
<span class="lineNum">      62 </span>                :            : #endif
<span class="lineNum">      63 </span>        [<span class="branchNoCov" title="Branch 1 was not taken"> - </span><span class="branchCov" title="Branch 2 was taken 6 times"> + </span>]:<span class="lineCov">          6 :     if (fcntl(sd, F_SETFL, fd_flags) == -1) {</span>
<span class="lineNum">      64 </span>                :<span class="lineNoCov">          0 :         return errno;</span>
<span class="lineNum">      65 </span>                :            :     }
<span class="lineNum">      66 </span>                :            : #else
<span class="lineNum">      67 </span>                :            :     int on = 1;
<span class="lineNum">      68 </span>                :            :     if (setsockopt(sd, SOL_SOCKET, SO_NONBLOCK, &amp;on, sizeof(int)) &lt; 0)
<span class="lineNum">      69 </span>                :            :         return errno;
<span class="lineNum">      70 </span>                :            : #endif /* BEOS */
<span class="lineNum">      71 </span>                :<span class="lineCov">          6 :     return APR_SUCCESS;</span>
<span class="lineNum">      72 </span>                :            : }
<span class="lineNum">      73 </span>                :            : 
<a name="74"><span class="lineNum">      74 </span>                :            : </a>
<span class="lineNum">      75 </span>                :            : apr_status_t apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t)
<span class="lineNum">      76 </span>                :<span class="lineCov">          5 : {</span>
<span class="lineNum">      77 </span>                :            :     apr_status_t stat;
<span class="lineNum">      78 </span>                :            : 
<span class="lineNum">      79 </span>                :            :     /* If our new timeout is non-negative and our old timeout was
<span class="lineNum">      80 </span>                :            :      * negative, then we need to ensure that we are non-blocking.
<span class="lineNum">      81 </span>                :            :      * Conversely, if our new timeout is negative and we had
<span class="lineNum">      82 </span>                :            :      * non-negative timeout, we must make sure our socket is blocking.
<span class="lineNum">      83 </span>                :            :      * We want to avoid calling fcntl more than necessary on the
<span class="lineNum">      84 </span>                :            :      * socket.
<span class="lineNum">      85 </span>                :            :      */
<span class="lineNum">      86 </span>[<span class="branchCov" title="Branch 0 was taken 5 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>][<span class="branchCov" title="Branch 2 was taken 5 times"> + </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span>]:<span class="lineCov">          5 :     if (t &gt;= 0 &amp;&amp; sock-&gt;timeout &lt; 0) {</span>
<span class="lineNum">      87 </span>        [<span class="branchCov" title="Branch 0 was taken 5 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          5 :         if (apr_is_option_set(sock, APR_SO_NONBLOCK) != 1) {</span>
<span class="lineNum">      88 </span>        [<span class="branchNoCov" title="Branch 1 was not taken"> - </span><span class="branchCov" title="Branch 2 was taken 5 times"> + </span>]:<span class="lineCov">          5 :             if ((stat = sononblock(sock-&gt;socketdes)) != APR_SUCCESS) {</span>
<span class="lineNum">      89 </span>                :<span class="lineNoCov">          0 :                 return stat;</span>
<span class="lineNum">      90 </span>                :            :             }
<span class="lineNum">      91 </span>                :<span class="lineCov">          5 :             apr_set_option(sock, APR_SO_NONBLOCK, 1);</span>
<span class="lineNum">      92 </span>                :            :         }
<span class="lineNum">      93 </span>                :            :     } 
<span class="lineNum">      94 </span>[<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>][<span class="branchNoExec" title="Branch 2 was not executed"> # </span><span class="branchNoExec" title="Branch 3 was not executed"> # </span>]:<span class="lineNoCov">          0 :     else if (t &lt; 0 &amp;&amp; sock-&gt;timeout &gt;= 0) {</span>
<span class="lineNum">      95 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (apr_is_option_set(sock, APR_SO_NONBLOCK) != 0) { </span>
<span class="lineNum">      96 </span>        [<span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span>]:<span class="lineNoCov">          0 :             if ((stat = soblock(sock-&gt;socketdes)) != APR_SUCCESS) { </span>
<span class="lineNum">      97 </span>                :<span class="lineNoCov">          0 :                 return stat; </span>
<span class="lineNum">      98 </span>                :            :             }
<span class="lineNum">      99 </span>                :<span class="lineNoCov">          0 :             apr_set_option(sock, APR_SO_NONBLOCK, 0);</span>
<span class="lineNum">     100 </span>                :            :         } 
<span class="lineNum">     101 </span>                :            :     }
<span class="lineNum">     102 </span>                :            :     /* must disable the incomplete read support if we disable
<span class="lineNum">     103 </span>                :            :      * a timeout
<span class="lineNum">     104 </span>                :            :      */
<span class="lineNum">     105 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 5 times"> + </span>]:<span class="lineCov">          5 :     if (t &lt;= 0) {</span>
<span class="lineNum">     106 </span>                :<span class="lineNoCov">          0 :         sock-&gt;options &amp;= ~APR_INCOMPLETE_READ;</span>
<span class="lineNum">     107 </span>                :            :     }
<span class="lineNum">     108 </span>                :<span class="lineCov">          5 :     sock-&gt;timeout = t;</span>
<span class="lineNum">     109 </span>                :<span class="lineCov">          5 :     return APR_SUCCESS;</span>
<span class="lineNum">     110 </span>                :            : }
<span class="lineNum">     111 </span>                :            : 
<span class="lineNum">     112 </span>                :            : 
<a name="113"><span class="lineNum">     113 </span>                :            : apr_status_t apr_socket_opt_set(apr_socket_t *sock, </a>
<span class="lineNum">     114 </span>                :            :                                 apr_int32_t opt, apr_int32_t on)
<span class="lineNum">     115 </span>                :<span class="lineCov">         17 : {</span>
<span class="lineNum">     116 </span>                :            :     int one;
<span class="lineNum">     117 </span>                :            :     apr_status_t rv;
<span class="lineNum">     118 </span>                :            : 
<span class="lineNum">     119 </span>        [<span class="branchCov" title="Branch 0 was taken 15 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">         17 :     if (on)</span>
<span class="lineNum">     120 </span>                :<span class="lineCov">         15 :         one = 1;</span>
<span class="lineNum">     121 </span>                :            :     else
<span class="lineNum">     122 </span>                :<span class="lineCov">          2 :         one = 0;</span>
<span class="lineNum">     123 </span>  [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span><span class="branchCov" title="Branch 2 was taken 10 times"> + </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span> :<span class="lineCov">         17 :     switch(opt) {</span>
<span class="lineNum">         </span><span class="branchNoCov" title="Branch 4 was not taken"> - </span><span class="branchCov" title="Branch 5 was taken 1 time"> + </span><span class="branchNoCov" title="Branch 6 was not taken"> - </span><span class="branchNoCov" title="Branch 7 was not taken"> - </span><span class="branchCov" title="Branch 8 was taken 1 time"> + </span> 
<span class="lineNum">         </span>   <span class="branchCov" title="Branch 9 was taken 2 times"> + </span><span class="branchNoCov" title="Branch 10 was not taken"> - </span><span class="branchNoCov" title="Branch 11 was not taken"> - </span><span class="branchNoCov" title="Branch 12 was not taken"> - </span>]
<span class="lineNum">     124 </span>                :            :     case APR_SO_KEEPALIVE:
<span class="lineNum">     125 </span>                :            : #ifdef SO_KEEPALIVE
<span class="lineNum">     126 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          2 :         if (on != apr_is_option_set(sock, APR_SO_KEEPALIVE)) {</span>
<span class="lineNum">     127 </span>        [<span class="branchNoCov" title="Branch 1 was not taken"> - </span><span class="branchCov" title="Branch 2 was taken 2 times"> + </span>]:<span class="lineCov">          2 :             if (setsockopt(sock-&gt;socketdes, SOL_SOCKET, SO_KEEPALIVE, (void *)&amp;one, sizeof(int)) == -1) {</span>
<span class="lineNum">     128 </span>                :<span class="lineNoCov">          0 :                 return errno;</span>
<span class="lineNum">     129 </span>                :            :             }
<span class="lineNum">     130 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span>]:<span class="lineCov">          2 :             apr_set_option(sock, APR_SO_KEEPALIVE, on);</span>
<span class="lineNum">     131 </span>                :            :         }
<span class="lineNum">     132 </span>                :            : #else
<span class="lineNum">     133 </span>                :            :         return APR_ENOTIMPL;
<span class="lineNum">     134 </span>                :            : #endif
<span class="lineNum">     135 </span>                :            :         break;
<span class="lineNum">     136 </span>                :            :     case APR_SO_DEBUG:
<span class="lineNum">     137 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          1 :         if (on != apr_is_option_set(sock, APR_SO_DEBUG)) {</span>
<span class="lineNum">     138 </span>        [<span class="branchCov" title="Branch 1 was taken 1 time"> + </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span>]:<span class="lineCov">          1 :             if (setsockopt(sock-&gt;socketdes, SOL_SOCKET, SO_DEBUG, (void *)&amp;one, sizeof(int)) == -1) {</span>
<span class="lineNum">     139 </span>                :<span class="lineCov">          1 :                 return errno;</span>
<span class="lineNum">     140 </span>                :            :             }
<span class="lineNum">     141 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :             apr_set_option(sock, APR_SO_DEBUG, on);</span>
<span class="lineNum">     142 </span>                :            :         }
<span class="lineNum">     143 </span>                :            :         break;
<span class="lineNum">     144 </span>                :            :     case APR_SO_REUSEADDR:
<span class="lineNum">     145 </span>        [<span class="branchCov" title="Branch 0 was taken 10 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">         10 :         if (on != apr_is_option_set(sock, APR_SO_REUSEADDR)) {</span>
<span class="lineNum">     146 </span>        [<span class="branchNoCov" title="Branch 1 was not taken"> - </span><span class="branchCov" title="Branch 2 was taken 10 times"> + </span>]:<span class="lineCov">         10 :             if (setsockopt(sock-&gt;socketdes, SOL_SOCKET, SO_REUSEADDR, (void *)&amp;one, sizeof(int)) == -1) {</span>
<span class="lineNum">     147 </span>                :<span class="lineNoCov">          0 :                 return errno;</span>
<span class="lineNum">     148 </span>                :            :             }
<span class="lineNum">     149 </span>        [<span class="branchCov" title="Branch 0 was taken 10 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">         10 :             apr_set_option(sock, APR_SO_REUSEADDR, on);</span>
<span class="lineNum">     150 </span>                :            :         }
<span class="lineNum">     151 </span>                :            :         break;
<span class="lineNum">     152 </span>                :            :     case APR_SO_SNDBUF:
<span class="lineNum">     153 </span>                :            : #ifdef SO_SNDBUF
<span class="lineNum">     154 </span>        [<span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (setsockopt(sock-&gt;socketdes, SOL_SOCKET, SO_SNDBUF, (void *)&amp;on, sizeof(int)) == -1) {</span>
<span class="lineNum">     155 </span>                :<span class="lineNoCov">          0 :             return errno;</span>
<span class="lineNum">     156 </span>                :            :         }
<span class="lineNum">     157 </span>                :            : #else
<span class="lineNum">     158 </span>                :            :         return APR_ENOTIMPL;
<span class="lineNum">     159 </span>                :            : #endif
<span class="lineNum">     160 </span>                :            :         break;
<span class="lineNum">     161 </span>                :            :     case APR_SO_RCVBUF:
<span class="lineNum">     162 </span>                :            : #ifdef SO_RCVBUF
<span class="lineNum">     163 </span>        [<span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (setsockopt(sock-&gt;socketdes, SOL_SOCKET, SO_RCVBUF, (void *)&amp;on, sizeof(int)) == -1) {</span>
<span class="lineNum">     164 </span>                :<span class="lineNoCov">          0 :             return errno;</span>
<span class="lineNum">     165 </span>                :            :         }
<span class="lineNum">     166 </span>                :            : #else
<span class="lineNum">     167 </span>                :            :         return APR_ENOTIMPL;
<span class="lineNum">     168 </span>                :            : #endif
<span class="lineNum">     169 </span>                :            :         break;
<span class="lineNum">     170 </span>                :            :     case APR_SO_NONBLOCK:
<span class="lineNum">     171 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          1 :         if (apr_is_option_set(sock, APR_SO_NONBLOCK) != on) {</span>
<span class="lineNum">     172 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          1 :             if (on) {</span>
<span class="lineNum">     173 </span>        [<span class="branchNoCov" title="Branch 1 was not taken"> - </span><span class="branchCov" title="Branch 2 was taken 1 time"> + </span>]:<span class="lineCov">          1 :                 if ((rv = sononblock(sock-&gt;socketdes)) != APR_SUCCESS) </span>
<span class="lineNum">     174 </span>                :<span class="lineNoCov">          0 :                     return rv;</span>
<span class="lineNum">     175 </span>                :            :             }
<span class="lineNum">     176 </span>                :            :             else {
<span class="lineNum">     177 </span>        [<span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 if ((rv = soblock(sock-&gt;socketdes)) != APR_SUCCESS)</span>
<span class="lineNum">     178 </span>                :<span class="lineNoCov">          0 :                     return rv;</span>
<span class="lineNum">     179 </span>                :            :             }
<span class="lineNum">     180 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          1 :             apr_set_option(sock, APR_SO_NONBLOCK, on);</span>
<span class="lineNum">     181 </span>                :            :         }
<span class="lineNum">     182 </span>                :            :         break;
<span class="lineNum">     183 </span>                :            :     case APR_SO_LINGER:
<span class="lineNum">     184 </span>                :            : #ifdef SO_LINGER
<span class="lineNum">     185 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (apr_is_option_set(sock, APR_SO_LINGER) != on) {</span>
<span class="lineNum">     186 </span>                :            :             struct linger li;
<span class="lineNum">     187 </span>                :<span class="lineNoCov">          0 :             li.l_onoff = on;</span>
<span class="lineNum">     188 </span>                :<span class="lineNoCov">          0 :             li.l_linger = APR_MAX_SECS_TO_LINGER;</span>
<span class="lineNum">     189 </span>        [<span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span>]:<span class="lineNoCov">          0 :             if (setsockopt(sock-&gt;socketdes, SOL_SOCKET, SO_LINGER, (char *) &amp;li, sizeof(struct linger)) == -1) {</span>
<span class="lineNum">     190 </span>                :<span class="lineNoCov">          0 :                 return errno;</span>
<span class="lineNum">     191 </span>                :            :             }
<span class="lineNum">     192 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :             apr_set_option(sock, APR_SO_LINGER, on);</span>
<span class="lineNum">     193 </span>                :            :         }
<span class="lineNum">     194 </span>                :            : #else
<span class="lineNum">     195 </span>                :            :         return APR_ENOTIMPL;
<span class="lineNum">     196 </span>                :            : #endif
<span class="lineNum">     197 </span>                :            :         break;
<span class="lineNum">     198 </span>                :            :     case APR_TCP_DEFER_ACCEPT:
<span class="lineNum">     199 </span>                :            : #if defined(TCP_DEFER_ACCEPT)
<span class="lineNum">     200 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (apr_is_option_set(sock, APR_TCP_DEFER_ACCEPT) != on) {</span>
<span class="lineNum">     201 </span>                :<span class="lineNoCov">          0 :             int optlevel = IPPROTO_TCP;</span>
<span class="lineNum">     202 </span>                :<span class="lineNoCov">          0 :             int optname = TCP_DEFER_ACCEPT;</span>
<span class="lineNum">     203 </span>                :            : 
<span class="lineNum">     204 </span>        [<span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span>]:<span class="lineNoCov">          0 :             if (setsockopt(sock-&gt;socketdes, optlevel, optname, </span>
<span class="lineNum">     205 </span>                :            :                            (void *)&amp;on, sizeof(int)) == -1) {
<span class="lineNum">     206 </span>                :<span class="lineNoCov">          0 :                 return errno;</span>
<span class="lineNum">     207 </span>                :            :             }
<span class="lineNum">     208 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :             apr_set_option(sock, APR_TCP_DEFER_ACCEPT, on);</span>
<span class="lineNum">     209 </span>                :            :         }
<span class="lineNum">     210 </span>                :            : #else
<span class="lineNum">     211 </span>                :            :         return APR_ENOTIMPL;
<span class="lineNum">     212 </span>                :            : #endif
<span class="lineNum">     213 </span>                :            :         break;
<span class="lineNum">     214 </span>                :            :     case APR_TCP_NODELAY:
<span class="lineNum">     215 </span>                :            : #if defined(TCP_NODELAY)
<span class="lineNum">     216 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          1 :         if (apr_is_option_set(sock, APR_TCP_NODELAY) != on) {</span>
<span class="lineNum">     217 </span>                :<span class="lineCov">          1 :             int optlevel = IPPROTO_TCP;</span>
<span class="lineNum">     218 </span>                :<span class="lineCov">          1 :             int optname = TCP_NODELAY;</span>
<span class="lineNum">     219 </span>                :            : 
<span class="lineNum">     220 </span>                :            : #if APR_HAVE_SCTP
<span class="lineNum">     221 </span>                :            :             if (sock-&gt;protocol == IPPROTO_SCTP) {
<span class="lineNum">     222 </span>                :            :                 optlevel = IPPROTO_SCTP;
<span class="lineNum">     223 </span>                :            :                 optname = SCTP_NODELAY;
<span class="lineNum">     224 </span>                :            :             }
<span class="lineNum">     225 </span>                :            : #endif
<span class="lineNum">     226 </span>        [<span class="branchNoCov" title="Branch 1 was not taken"> - </span><span class="branchCov" title="Branch 2 was taken 1 time"> + </span>]:<span class="lineCov">          1 :             if (setsockopt(sock-&gt;socketdes, optlevel, optname, (void *)&amp;on, sizeof(int)) == -1) {</span>
<span class="lineNum">     227 </span>                :<span class="lineNoCov">          0 :                 return errno;</span>
<span class="lineNum">     228 </span>                :            :             }
<span class="lineNum">     229 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          1 :             apr_set_option(sock, APR_TCP_NODELAY, on);</span>
<span class="lineNum">     230 </span>                :            :         }
<span class="lineNum">     231 </span>                :            : #else
<span class="lineNum">     232 </span>                :            :         /* BeOS pre-BONE has TCP_NODELAY set by default.
<span class="lineNum">     233 </span>                :            :          * As it can't be turned off we might as well check if they're asking
<span class="lineNum">     234 </span>                :            :          * for it to be turned on!
<span class="lineNum">     235 </span>                :            :          */
<span class="lineNum">     236 </span>                :            : #ifdef BEOS
<span class="lineNum">     237 </span>                :            :         if (on == 1)
<span class="lineNum">     238 </span>                :            :             return APR_SUCCESS;
<span class="lineNum">     239 </span>                :            :         else
<span class="lineNum">     240 </span>                :            : #endif
<span class="lineNum">     241 </span>                :            :         return APR_ENOTIMPL;
<span class="lineNum">     242 </span>                :            : #endif
<span class="lineNum">     243 </span>                :            :         break;
<span class="lineNum">     244 </span>                :            :     case APR_TCP_NOPUSH:
<span class="lineNum">     245 </span>                :            : #if APR_TCP_NOPUSH_FLAG
<span class="lineNum">     246 </span>                :            :         /* TCP_NODELAY and TCP_CORK are mutually exclusive on Linux
<span class="lineNum">     247 </span>                :            :          * kernels &lt; 2.6; on newer kernels they can be used together
<span class="lineNum">     248 </span>                :            :          * and TCP_CORK takes preference, which is the desired
<span class="lineNum">     249 </span>                :            :          * behaviour.  On older kernels, TCP_NODELAY must be toggled
<span class="lineNum">     250 </span>                :            :          * to &quot;off&quot; whilst TCP_CORK is in effect. */
<span class="lineNum">     251 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          2 :         if (apr_is_option_set(sock, APR_TCP_NOPUSH) != on) {</span>
<span class="lineNum">     252 </span>                :            : #ifndef HAVE_TCP_NODELAY_WITH_CORK
<span class="lineNum">     253 </span>                :            :             int optlevel = IPPROTO_TCP;
<span class="lineNum">     254 </span>                :            :             int optname = TCP_NODELAY;
<span class="lineNum">     255 </span>                :            : 
<span class="lineNum">     256 </span>                :            : #if APR_HAVE_SCTP
<span class="lineNum">     257 </span>                :            :             if (sock-&gt;protocol == IPPROTO_SCTP) {
<span class="lineNum">     258 </span>                :            :                 optlevel = IPPROTO_SCTP;
<span class="lineNum">     259 </span>                :            :                 optname = SCTP_NODELAY;
<span class="lineNum">     260 </span>                :            :             }
<span class="lineNum">     261 </span>                :            : #endif
<span class="lineNum">     262 </span>                :            :             /* OK we're going to change some settings here... */
<span class="lineNum">     263 </span>                :            :             if (apr_is_option_set(sock, APR_TCP_NODELAY) == 1 &amp;&amp; on) {
<span class="lineNum">     264 </span>                :            :                 /* Now toggle TCP_NODELAY to off, if TCP_CORK is being
<span class="lineNum">     265 </span>                :            :                  * turned on: */
<span class="lineNum">     266 </span>                :            :                 int tmpflag = 0;
<span class="lineNum">     267 </span>                :            :                 if (setsockopt(sock-&gt;socketdes, optlevel, optname,
<span class="lineNum">     268 </span>                :            :                                (void*)&amp;tmpflag, sizeof(int)) == -1) {
<span class="lineNum">     269 </span>                :            :                     return errno;
<span class="lineNum">     270 </span>                :            :                 }
<span class="lineNum">     271 </span>                :            :                 apr_set_option(sock, APR_RESET_NODELAY, 1);
<span class="lineNum">     272 </span>                :            :                 apr_set_option(sock, APR_TCP_NODELAY, 0);
<span class="lineNum">     273 </span>                :            :             } else if (on) {
<span class="lineNum">     274 </span>                :            :                 apr_set_option(sock, APR_RESET_NODELAY, 0);
<span class="lineNum">     275 </span>                :            :             }
<span class="lineNum">     276 </span>                :            : #endif /* HAVE_TCP_NODELAY_WITH_CORK */
<span class="lineNum">     277 </span>                :            : 
<span class="lineNum">     278 </span>                :            :             /* OK, now we can just set the TCP_NOPUSH flag accordingly...*/
<span class="lineNum">     279 </span>        [<span class="branchNoCov" title="Branch 1 was not taken"> - </span><span class="branchCov" title="Branch 2 was taken 2 times"> + </span>]:<span class="lineCov">          2 :             if (setsockopt(sock-&gt;socketdes, IPPROTO_TCP, APR_TCP_NOPUSH_FLAG,</span>
<span class="lineNum">     280 </span>                :            :                            (void*)&amp;on, sizeof(int)) == -1) {
<span class="lineNum">     281 </span>                :<span class="lineNoCov">          0 :                 return errno;</span>
<span class="lineNum">     282 </span>                :            :             }
<span class="lineNum">     283 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span>]:<span class="lineCov">          2 :             apr_set_option(sock, APR_TCP_NOPUSH, on);</span>
<span class="lineNum">     284 </span>                :            : #ifndef HAVE_TCP_NODELAY_WITH_CORK
<span class="lineNum">     285 </span>                :            :             if (!on &amp;&amp; apr_is_option_set(sock, APR_RESET_NODELAY)) {
<span class="lineNum">     286 </span>                :            :                 /* Now, if TCP_CORK was just turned off, turn
<span class="lineNum">     287 </span>                :            :                  * TCP_NODELAY back on again if it was earlier toggled
<span class="lineNum">     288 </span>                :            :                  * to off: */
<span class="lineNum">     289 </span>                :            :                 int tmpflag = 1;
<span class="lineNum">     290 </span>                :            :                 if (setsockopt(sock-&gt;socketdes, optlevel, optname,
<span class="lineNum">     291 </span>                :            :                                (void*)&amp;tmpflag, sizeof(int)) == -1) {
<span class="lineNum">     292 </span>                :            :                     return errno;
<span class="lineNum">     293 </span>                :            :                 }
<span class="lineNum">     294 </span>                :            :                 apr_set_option(sock, APR_RESET_NODELAY,0);
<span class="lineNum">     295 </span>                :            :                 apr_set_option(sock, APR_TCP_NODELAY, 1);
<span class="lineNum">     296 </span>                :            :             }
<span class="lineNum">     297 </span>                :            : #endif /* HAVE_TCP_NODELAY_WITH_CORK */
<span class="lineNum">     298 </span>                :            :         }
<span class="lineNum">     299 </span>                :            : #else
<span class="lineNum">     300 </span>                :            :         return APR_ENOTIMPL;
<span class="lineNum">     301 </span>                :            : #endif
<span class="lineNum">     302 </span>                :            :         break;
<span class="lineNum">     303 </span>                :            :     case APR_INCOMPLETE_READ:
<span class="lineNum">     304 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :         apr_set_option(sock, APR_INCOMPLETE_READ, on);</span>
<span class="lineNum">     305 </span>                :            :         break;
<span class="lineNum">     306 </span>                :            :     case APR_IPV6_V6ONLY:
<span class="lineNum">     307 </span>                :            : #if APR_HAVE_IPV6 &amp;&amp; defined(IPV6_V6ONLY)
<span class="lineNum">     308 </span>                :            :         /* we don't know the initial setting of this option,
<span class="lineNum">     309 </span>                :            :          * so don't check sock-&gt;options since that optimization
<span class="lineNum">     310 </span>                :            :          * won't work
<span class="lineNum">     311 </span>                :            :          */
<span class="lineNum">     312 </span>        [<span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (setsockopt(sock-&gt;socketdes, IPPROTO_IPV6, IPV6_V6ONLY,</span>
<span class="lineNum">     313 </span>                :            :                        (void *)&amp;on, sizeof(int)) == -1) {
<span class="lineNum">     314 </span>                :<span class="lineNoCov">          0 :             return errno;</span>
<span class="lineNum">     315 </span>                :            :         }
<span class="lineNum">     316 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :         apr_set_option(sock, APR_IPV6_V6ONLY, on);</span>
<span class="lineNum">     317 </span>                :            : #else
<span class="lineNum">     318 </span>                :            :         return APR_ENOTIMPL;
<span class="lineNum">     319 </span>                :            : #endif
<span class="lineNum">     320 </span>                :            :         break;
<span class="lineNum">     321 </span>                :            :     default:
<span class="lineNum">     322 </span>                :<span class="lineNoCov">          0 :         return APR_EINVAL;</span>
<span class="lineNum">     323 </span>                :            :     }
<span class="lineNum">     324 </span>                :            : 
<span class="lineNum">     325 </span>                :<span class="lineCov">         17 :     return APR_SUCCESS; </span>
<span class="lineNum">     326 </span>                :            : }         
<span class="lineNum">     327 </span>                :            : 
<a name="328"><span class="lineNum">     328 </span>                :            : </a>
<span class="lineNum">     329 </span>                :            : apr_status_t apr_socket_timeout_get(apr_socket_t *sock, apr_interval_time_t *t)
<span class="lineNum">     330 </span>                :<span class="lineNoCov">          0 : {</span>
<span class="lineNum">     331 </span>                :<span class="lineNoCov">          0 :     *t = sock-&gt;timeout;</span>
<span class="lineNum">     332 </span>                :<span class="lineNoCov">          0 :     return APR_SUCCESS;</span>
<span class="lineNum">     333 </span>                :            : }
<span class="lineNum">     334 </span>                :            : 
<span class="lineNum">     335 </span>                :            : 
<a name="336"><span class="lineNum">     336 </span>                :            : apr_status_t apr_socket_opt_get(apr_socket_t *sock, </a>
<span class="lineNum">     337 </span>                :            :                                 apr_int32_t opt, apr_int32_t *on)
<span class="lineNum">     338 </span>                :<span class="lineCov">          8 : {</span>
<span class="lineNum">     339 </span>                :            :     switch(opt) {
<span class="lineNum">     340 </span>                :            :         default:
<span class="lineNum">     341 </span>                :<span class="lineCov">          8 :             *on = apr_is_option_set(sock, opt);</span>
<span class="lineNum">     342 </span>                :            :     }
<span class="lineNum">     343 </span>                :<span class="lineCov">          8 :     return APR_SUCCESS;</span>
<span class="lineNum">     344 </span>                :            : }
<span class="lineNum">     345 </span>                :            : 
<a name="346"><span class="lineNum">     346 </span>                :            : </a>
<span class="lineNum">     347 </span>                :            : apr_status_t apr_socket_atmark(apr_socket_t *sock, int *atmark)
<span class="lineNum">     348 </span>                :<span class="lineNoCov">          0 : {</span>
<span class="lineNum">     349 </span>                :            : #ifndef BEOS_R5
<span class="lineNum">     350 </span>                :            :     int oobmark;
<span class="lineNum">     351 </span>                :            : 
<span class="lineNum">     352 </span>        [<span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (ioctl(sock-&gt;socketdes, SIOCATMARK, (void*) &amp;oobmark) &lt; 0)</span>
<span class="lineNum">     353 </span>                :<span class="lineNoCov">          0 :         return apr_get_netos_error();</span>
<span class="lineNum">     354 </span>                :            : 
<span class="lineNum">     355 </span>                :<span class="lineNoCov">          0 :     *atmark = (oobmark != 0);</span>
<span class="lineNum">     356 </span>                :            : 
<span class="lineNum">     357 </span>                :<span class="lineNoCov">          0 :     return APR_SUCCESS;</span>
<span class="lineNum">     358 </span>                :            : #else /* BEOS_R5 */
<span class="lineNum">     359 </span>                :            :     return APR_ENOTIMPL;
<span class="lineNum">     360 </span>                :            : #endif
<span class="lineNum">     361 </span>                :            : }
<a name="362"><span class="lineNum">     362 </span>                :            : </a>
<span class="lineNum">     363 </span>                :            : apr_status_t apr_gethostname(char *buf, apr_int32_t len, apr_pool_t *cont)
<span class="lineNum">     364 </span>                :<span class="lineNoCov">          0 : {</span>
<span class="lineNum">     365 </span>                :            : #ifdef BEOS_R5
<span class="lineNum">     366 </span>                :            :     if (gethostname(buf, len) == 0) {
<span class="lineNum">     367 </span>                :            : #else
<span class="lineNum">     368 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (gethostname(buf, len) != 0) {</span>
<span class="lineNum">     369 </span>                :            : #endif  
<span class="lineNum">     370 </span>                :<span class="lineNoCov">          0 :         buf[0] = '\0';</span>
<span class="lineNum">     371 </span>                :<span class="lineNoCov">          0 :         return errno;</span>
<span class="lineNum">     372 </span>                :            :     }
<span class="lineNum">     373 </span>        [<span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span>]:<span class="lineNoCov">          0 :     else if (!memchr(buf, '\0', len)) { /* buffer too small */</span>
<span class="lineNum">     374 </span>                :            :         /* note... most platforms just truncate in this condition
<span class="lineNum">     375 </span>                :            :          *         linux+glibc return an error
<span class="lineNum">     376 </span>                :            :          */
<span class="lineNum">     377 </span>                :<span class="lineNoCov">          0 :         buf[0] = '\0';</span>
<span class="lineNum">     378 </span>                :<span class="lineNoCov">          0 :         return APR_ENAMETOOLONG;</span>
<span class="lineNum">     379 </span>                :            :     }
<span class="lineNum">     380 </span>                :<span class="lineNoCov">          0 :     return APR_SUCCESS;</span>
<span class="lineNum">     381 </span>                :            : }
<span class="lineNum">     382 </span>                :            : 
<span class="lineNum">     383 </span>                :            : #if APR_HAS_SO_ACCEPTFILTER
<span class="lineNum">     384 </span>                :            : apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *name, 
<span class="lineNum">     385 </span>                :            :                                       char *args)
<span class="lineNum">     386 </span>                :            : {
<span class="lineNum">     387 </span>                :            :     struct accept_filter_arg af;
<span class="lineNum">     388 </span>                :            :     strncpy(af.af_name, name, 16);
<span class="lineNum">     389 </span>                :            :     strncpy(af.af_arg, args, 256 - 16);
<span class="lineNum">     390 </span>                :            : 
<span class="lineNum">     391 </span>                :            :     if ((setsockopt(sock-&gt;socketdes, SOL_SOCKET, SO_ACCEPTFILTER,
<span class="lineNum">     392 </span>                :            :           &amp;af, sizeof(af))) &lt; 0) {
<span class="lineNum">     393 </span>                :            :         return errno;
<span class="lineNum">     394 </span>                :            :     }
<span class="lineNum">     395 </span>                :            :     return APR_SUCCESS;
<span class="lineNum">     396 </span>                :            : }
<span class="lineNum">     397 </span>                :            : #endif
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.9</a></td></tr>
  </table>
  <br>

</body>
</html>
